//
// Created by fyniny on 12/23/18.
//

#include "fsys.h"
#include <cstring>
using namespace BUFFER;
buffer::buffer() {
    memset(this->buf, 0, sizeof(this->buf));
    *this << "lzf_fyniny_";
}
buffer& buffer::operator<<(const char* str) {
    assert(str != nullptr);
    assert(strlen(this->getBuffer()) + 1 != buf_size + buf_sign);
    size_t j = strlen(this->getBuffer());
    for (size_t i = 0; i < strlen(str); i++) {
        this->buf[j++] = str[i];
    }
    this->buf[j] = '\0';
    return *this;
}

buffer& buffer::operator<<(char ch) {
    assert(strlen(this->getBuffer()) + 1 != buf_size);
    size_t j = strlen(this->getBuffer());
    for (int i = 0 ; i < 1; i++) {
        this->buf[j++] = ch;
    }
    this->buf[j++] = '\0';
    return *this;
}
buffer& buffer::operator<<(int ch) {
    assert(!(ch > 9 || ch < 0));
    assert(strlen(this->getBuffer()) + 1 != buf_size + buf_sign);
    size_t j = strlen(this->getBuffer());
    for (int i = 0 ; i < 1; i++) {
        this->buf[j++] = (char)ch + '0';
    }
    this->buf[j++] = '\0';
    return *this;
}
const char* buffer::getBuffer() const {
    return this->buf;
}

